<?php

	include 'config.inc.php';
			
	$locationName = "";
	
	session_start();
	
	if( isset( $_GET['page'] ) && $_GET['page'] != "" )	$page = $_GET['page'];
	else $page = 'start';
	
	if( isset( $_GET['module'] ) && $_GET['module'] != "" )	$module = $_GET['module'];
	else $module = "";
	
	
	try{

		$db = @new mysqli( $db_host,$db_user,$db_pass,$db_name );
		if ( !mysqli_connect_errno() ){
			
			$sql = "SELECT `name` FROM `standort`";
		    $locations = $db->query( $sql );
			    
		    if( $locations->num_rows > 0 ){
					    	
				while( $location = $locations->fetch_object() ){
				
					$locationName = $location->name;
					
				}

			}else{
					  			    
				throw new Exception( 'Die Abfrage '.$sql.' liefert keine Ergebnisse' );
					
			}
			
			$locations->close();
			    
		}else{
				
			throw new Exception( 'Die Datenbank konnte nicht erreicht werden. Folgender Fehler trat auf: <strong>' .mysqli_connect_errno(). ' : ' .mysqli_connect_error(). '</strong>' );
				  
		}
			
		$db->close();
		
	}catch( Exception $e ){
		
		echo '<pre><b>Exception</b>'."\n"; 
		echo $e->getMessage();
		echo '</pre>';
		   
	}
	
	
	echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
		<title>Ketex³ | <?php echo $locationName; ?></title>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet" type="text/css" href="css/ketex_default.css" />
	</head>
	<body>
		<div id="statusbar">
			<?php include 'login.php'; ?>
		</div>
		<div id="header">
			<!-- h1><a href="index.php">KETEX<sup>3</sup> <?php echo $locationName; ?></a></h1 -->
			<h1><a href="index.php"><?php echo $locationName; ?></a></h1>
			<div id="navigation">
				<?php include 'navigation.php'; ?>
			</div>
		</div>
		<div id="maincontent">
			<?php include 'content.php'; ?>
		</div>
		<div id="footer">
			<?php include 'subnavigation.php'; ?>
		</div>
		<div id="legalbar"><b>KETEX<sup>3</sup></b> Dienstplanverwaltung</div>
	</body>
</html>